<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            height: 2000px;
        }
        div{
            position: absolute;
            left: 0;
            top: 0;
            width: 300px;
            height: 300px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div></div>
    <script>
        var div = document.querySelector("div");
        var x = 0,y = 0;

        div.addEventListener("touchstart",function(e){
            x = e.targetTouches[0].pageX - div.offsetLeft;
            y = e.targetTouches[0].pageY - div.offsetTop;
        })

        div.addEventListener("touchmove",function(e){
            e.preventDefault();
            div.style.left = e.targetTouches[0].pageX - x + "px";
            div.style.top = e.targetTouches[0].pageY - y + "px"

        })
    </script>
</body>
</html>